var App = require('app');

App.AppEditController = Em.ObjectController.extend({    
    saveApp: function() {
       	var me = this;
       	
       	var appId = Vari.app.get("id");
       	var type = null;
       	if (appId == null) {
       		type = "POST";
		} else {
			type = "PUT";
		}
       	
    	var json = $.toJSON(Vari.app);
    	$.ajax({
			type : type,
			dataType: 'json',
			contentType: 'application/json; charset=utf-8',

			async : false,
			url : Vari.ApiRestV1 + 'apps',
			data : json,

			success : function(json) {
				me.transitionToRoute("apps");
			}
		});
    }
});